package com.wanaofu.managedbeans 

import javax.el.ELResolver
import javax.faces.bean.ManagedBean
import javax.faces.bean.ManagedProperty
import javax.faces.bean.SessionScoped
import javax.faces.context.FacesContext

import com.wanaofu.service.WarehouseService

//@ManagedBean(name="hello_groovy")
//@SessionScoped
class HelloWorldGroovy {
	private  static  final  long  serialVersionUID  =  6866250699219535733L
	private  String  name
 
//	@ManagedProperty(name="warehouseService", value="#{warehouseService}")
//	private WarehouseService warehouseService
	
	public  String  getName()  {
			FacesContext fc = FacesContext.getCurrentInstance()
			ELResolver elResolver = fc.getApplication().getELResolver()
		
			WarehouseService warehouseService = elResolver.getValue(
			  fc.getELContext(), null, "warehouseService")
		
		   this.name  =  warehouseService.getProductInfoByCode("P001").getShortName() ;
		   return  name;
	}

}
